package com.sgb.kjwl.view.ui.adapter.home;

import android.text.TextUtils;

import com.blankj.utilcode.util.ColorUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemGoodsCompanyBindingImpl;
import com.sgb.kjwl.databinding.ItemGoodsIndexBinding;
import com.sgb.kjwl.databinding.ItemGoodsIndexCompanyBinding;
import com.sgb.kjwl.model.entity.businessmanagement.GoodsIndexMemberEntity;
import com.sgb.kjwl.model.entity.businessmanagement.MemberEntity;
import com.sgb.kjwl.model.entity.user.GoodsIndexEntity;
import com.sgb.kjwl.view.ui.adapter.self.order.DataBindingViewHolder;

import java.util.List;

/**
 * @author PC
 */
public class GoodsCompanyAdapter extends BaseQuickAdapter<GoodsIndexMemberEntity, DataBindingViewHolder> {

    private ItemGoodsIndexCompanyBinding binding;

    public GoodsCompanyAdapter(List<GoodsIndexMemberEntity> data) {
        super(R.layout.item_goods_index_company, data);
    }

    @Override
    protected void convert(DataBindingViewHolder helper, GoodsIndexMemberEntity item) {
        binding = (ItemGoodsIndexCompanyBinding) helper.getBinding();
        String companyName = "";
        //0 成员 1 会员 2 关注 3 推荐
        if ("0".equals(item.getType())) {
            companyName = item.getName();
        } else if ("1".equals(item.getType()) || "2".equals(item.getType())) {
            companyName = item.getCompanyName();
        } else if ("3".equals(item.getType())) {
            companyName = item.getSupplierName();
        }

        if (!TextUtils.isEmpty(companyName) && companyName.length() > 6) {
            companyName = companyName.substring(0, 6) + "...>";
        } else {
            companyName = companyName + ">";
        }
        binding.tvTitle.setText(companyName);
    }

}
